<template>
	<view>
		<view class="PreferredLoanHead">
			应监管要求，请上传证件上传
		</view>
		<view class="PreferredLoanHeadMoney">
			<view style="padding-bottom: 30rpx;border-bottom: 1px solid #E4E4E4;margin-bottom: 20rpx;">
				<text style="font-size: 72rpx;float: left;color: #000000;">￥</text>
				<input type="number" value="" v-model="money" class="PreferredLoanHeadMoneyInput"  placeholder="请输入贷款金额" />
			</view>
			<view>单笔可借1000-20000元，请输入1000的整数倍</view>
			<view class="PreferredLoanHeadMoneyRequirement">期限3-24月 | 日息0.03%起 | 快至1分钟到账</view>
		</view>
		<view class="PreferredLoanHeadBottom">
			<view class="PreferredLoanHeadBottomChoice" @click="PreferredLoanClick(1)">
				<text>实名认证</text>
				<text :class="authentica1 == '已认证' ? 'PreferredLoanHeadBottomChoiceRight':'PreferredLoanHeadBottomChoiceRight2'">{{authentica1}}</text>
			</view>
			<view class="PreferredLoanHeadBottomChoice" @click="PreferredLoanClick(2)">
				<text>基本信息</text>
				<text :class="authentica2 == '已认证' ? 'PreferredLoanHeadBottomChoiceRight':'PreferredLoanHeadBottomChoiceRight2'">{{authentica2}}</text>
			</view>
			<view class="PreferredLoanHeadBottomChoice" @click="PreferredLoanClick(3)">
				<text>补充信息</text>
				<text :class="authentica3 == '已认证' ? 'PreferredLoanHeadBottomChoiceRight':'PreferredLoanHeadBottomChoiceRight2'">{{authentica3}}</text>
			</view>
			<view class="PreferredLoanHeadBottomChoice" @click="PreferredLoanClick(4)">
				<text>提额信息</text>
				<text :class="authentica4 == '已认证' ? 'PreferredLoanHeadBottomChoiceRight':'PreferredLoanHeadBottomChoiceRight2'">{{authentica4}}</text>
			</view>
		</view>
		<view class="PreferredLoanHeadBottomRequirement">
			<checkbox-group @change="checkboxChange">
				<checkbox value="cb" checked="true" style="transform:scale(0.7);" />
			</checkbox-group>
			同意<text style="color: #DFAF80;" @click="PreferredLoanClick(6)">《机构授权协议》</text>
		</view>
		<view class="PreferredLoanHeadBottomInput" @click="PreferredLoanClick(5)">
			<view style="width: 650rpx;height: 95rpx;background: linear-gradient(-84deg, #DFBA94, #DFAE7C);
						box-shadow: 1px 3px 10px 0px rgba(0, 0, 0, 0.16);border-radius: 48rpx;margin: auto;line-height: 95rpx;">
				马上领钱
			</view>
		</view>
		<view class="tc" v-if="tanchuang">
			<view class="tcwhict">
				<view style="font-size: 36rpx;font-weight: bold;color: #000000;padding: 60rpx 0 30rpx 0;box-sizing: border-box;">
					温馨提示
				</view>
				<view style="font-size: 26rpx;font-weight: 500;color: #888888;margin-bottom: 60rpx;">
					您确定退出登录吗？
				</view>
				<view style="width: 206rpx;height: 69rpx;border: 1px solid #DFB080;border-radius: 35rpx;font-size: 30rpx;font-weight: bold;
								color: #DFAF80;text-align: center;line-height: 69rpx;display: inline-block;margin-right: 30rpx;" @click="QvXiao()">
					取消
				</view>
				<view style="width: 206rpx;height: 69rpx;background: linear-gradient(-84deg, #DFBA94, #DFAE7C);border-radius: 35px;
						font-size: 30rpx;font-weight: bold;color: #FFFFFF;text-align: center;line-height: 69rpx;display: inline-block;" @click="QveDing()">
					确定
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {VUE_API_URL} from "@/components/pulugins/index"
	export default {
		components: {
			
		},
		data() {
			return {
				money:'',
				tanchuang:false,
				token:'',
				Agreement:true,
				authentication:'',
				authentica1:'去认证',
				authentica2:'去认证',
				authentica3:'去认证',
				authentica4:'去认证'
			}
		},
		onBackPress(e) {
		    console.log(e);
		    if (options.from === 'navigateBack') {
				this.tanchuang = true;
		        return false;
		    }
		},
		onLoad() {
			var that = this;
			that.token = uni.getStorageSync('token');
			that.UserInfo();
		},
		methods: {
			UserInfo(){
				var that = this;
				that.token = uni.getStorageSync('token');
				uni.request({
				    url: VUE_API_URL + '/user/info', 
					method:'POST',
				    data: {
				        
				    },
				    header: {
				        'Authori-zation': 'Bearer ' + that.token //自定义请求头信息
				    },
				    success: (res) => {
						console.log(res);
						var authentica = res.data.data.authentication;
						var arr = authentica.split(',');
						for(var i=0;i<arr.length;i++){
							if(arr[i]==1){
								that.authentica1='已认证'
							}else if(arr[i]==2){
								that.authentica2='已认证'
							}else if(arr[i]==3){
								that.authentica3='已认证'
							}else if(arr[i]==4){
								that.authentica4='已认证'
							}
						}
				    }
				});	 
			},
			checkboxChange: function (e) {
				var that = this;
				if(e.detail.value == ''){
					that.Agreement = false;
				}else{
					that.Agreement = true;
				}
				console.log(that.Agreement)
			},
			PreferredLoanClick(index){
				var that = this;
				if(index == 1){
					uni.navigateTo({
						url: '../second/RealNameAuthentication'
					});
				}else if(index == 2){
					uni.navigateTo({
						url: '../second/EssentialInformation'
					});
				}else if(index == 3){
					uni.navigateTo({
					    url: '../second/Supplement'
					});
				}else if(index == 4){ 
					uni.navigateTo({
					    url: '../second/IncreaseInformation'
					});
				}else if(index == 5){
					if(that.money == ''){
						uni.showToast({
						    title: '请输入金额',
							icon:'none',
						    duration: 2000
						});
					}else if(that.money%1000 != 0){
						uni.showToast({
						    title: '请输入1000的整数倍',
							icon:'none',
						    duration: 2000
						});
					}else if(that.Agreement == false){
						uni.showToast({
						    title: '请勾选机构授权协议',
							icon:'none',
						    duration: 2000
						});
					}else if(that.authentica1=='去认证' || that.authentica2=='去认证' || that.authentica3=='去认证'){
						uni.showToast({
						    title: '请完成实名认证，基本信息和补充信息',
							icon:'none',
						    duration: 2000
						});
					}else{
						uni.navigateTo({
						    url: '../second/receiveQuota'
						});
					}
				}else if(index == 6){
					uni.navigateTo({
					    url: '../second/PrivacyAgreement'
					});
				}
			},
			QvXiao(){
				this.tanchuang = false;
			},
			QveDing(){
				uni.switchTab({
				    url: '/pages/index/index'
				});
			}
		},
	}
</script>

<style>
	uni-checkbox-group{
		display: inline-block;
	}
	.tcwhict{
		width: 545rpx;
		height: 360rpx;
		background: #FFFFFF;
		margin: auto;
		position: relative;
		top: 35%;
		border-radius: 20rpx;
		font-family: PingFang SC;
		text-align: center;
	}
	.tc{
		width: 100%;
		height: 100%;
		position: fixed;
		top: 0;
		background: rgba(0,0,0,0.5);
		z-index: 999;
	}
	.PreferredLoanHeadBottomInput{
		width: 100%;
		background: #FFFFFF;
		position: fixed;
		bottom: 0;
		height: 150rpx;
		font-size: 36rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #FFFFFF;
		text-align: center;
		box-sizing: border-box;
		padding-top: 30rpx;
	}
	.PreferredLoanHeadBottomRequirement{
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #888888;
		text-align: center;
		margin-top: 50rpx;
	}
	.uni-checkbox-input{
		color: #FFFFFF !important;
		background: red !important;
	}
	.PreferredLoanHeadBottomChoiceRight2{
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #DFAF80;
		padding: 8rpx 14rpx;
		background: #FBE5CE;
		border-radius: 23rpx;
		float: right;
	}
	.PreferredLoanHeadBottomChoiceRight{
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #888888;
		padding: 8rpx 14rpx;
		background: #F8F8F8;
		border-radius: 23rpx;
		float: right;
	}
	.PreferredLoanHeadBottomChoice{
		height: 110rpx;
		border-bottom: 1px solid #F8F8F8;
		font-size: 32rpx;
		font-family: AaHeiTi-Li;
		font-weight: 400;
		color: #000000;
		padding: 30rpx 50rpx 0 50rpx;
		box-sizing: border-box;
	}
	.PreferredLoanHeadBottom{
		background: #FFFFFF;
		width: 100%;
		margin-top: 37rpx;
	}
	.PreferredLoanHeadMoneyInput{
		font-size: 55rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #000000;
		position: relative;
		top: 10rpx;
	}
	.PreferredLoanHeadMoneyRequirement{
		display: inline-block;
		height: 40rpx;
		background: #F2F2F2;
		border-radius: 5rpx;
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #888888;
		line-height: 40rpx;
		text-align: center;
		padding: 0 15rpx;
		box-sizing: border-box;
		margin-top: 32rpx;
	}
	.PreferredLoanHeadMoney{
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #B0B0B0;
		padding: 36rpx 50rpx;
		box-sizing: border-box;
		background: #FFFFFF;
	}
	.PreferredLoanHead{
		width: 100%;
		height: 50rpx;
		line-height: 50rpx;
		background: #FBE5CE;
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #DFAF80;
		padding: 0 30rpx;
		box-sizing: border-box;
	}
	page{
		background: #F8F8F8;
	}
</style>
